package manong.mapper;

import manong.beans.Classroom;
import manong.beans.ClassroomQuery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
@Mapper
public interface ClassroomMapper {
  
    long countByExample(ClassroomQuery example);


    int deleteByExample(ClassroomQuery example);

   
    @Delete({
        "delete from classroom",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

 
    @Insert({
        "insert into classroom (room_name, room_space, ",
        "room_layer, room_sign, ",
        "statu, mark)",
        "values (#{roomName,jdbcType=VARCHAR}, #{roomSpace,jdbcType=INTEGER}, ",
        "#{roomLayer,jdbcType=INTEGER}, #{roomSign,jdbcType=INTEGER}, ",
        "#{statu,jdbcType=INTEGER}, #{mark,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(Classroom record);

    int insertSelective(Classroom record);

    List<Classroom> selectByExampleWithRowbounds(ClassroomQuery example, RowBounds rowBounds);

  
    Classroom selectOneByExample(ClassroomQuery example);

  
    List<Classroom> selectByExample(ClassroomQuery example);
  //此处经过idea的调试--》跳到mapper的xml配置文件--》82-86 复杂的sql被抽取出来，用include给抽取出来--》走下一次返回业务层
   
    @Select({
        "select",
        "id, room_name, room_space, room_layer, room_sign, statu, mark",
        "from classroom",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("manong.mapper.ClassroomMapper.BaseResultMap")
    Classroom selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Classroom record, @Param("example") ClassroomQuery example);

    int updateByExample(@Param("record") Classroom record, @Param("example") ClassroomQuery example);

   
    int updateByPrimaryKeySelective(Classroom record);

  
    @Update({
        "update classroom",
        "set room_name = #{roomName,jdbcType=VARCHAR},",
          "room_space = #{roomSpace,jdbcType=INTEGER},",
          "room_layer = #{roomLayer,jdbcType=INTEGER},",
          "room_sign = #{roomSign,jdbcType=INTEGER},",
          "statu = #{statu,jdbcType=INTEGER},",
          "mark = #{mark,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Classroom record);

    
    int insertOrUpdate(Classroom record);

    
    int insertOrUpdateSelective(Classroom record);

 
    int batchInsert(@Param("list") List<Classroom> list);

      int batchInsertSelective(@Param("list") List<Classroom> list, @Param("selective") Classroom.Column ... selective);
}